package com.chengqj;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.mongodb.MongoDatabaseFactory;
import org.springframework.data.mongodb.MongoTransactionManager;

/**
 * Copyright © 2021年 tx-demo. All rights reserved.
 *
 * @author chengqj
 * 使用自定义事务管理
 * version 1.0.0 (接口必须带上)
 * @date 2021/3/3 15:49
 */
@Configuration
public class TransactionConfigure {
    @Bean
    @Primary
    public JtaDefinesTransaction jtaDefinesTransaction(MongoDatabaseFactory factory, MongoUtils mongoUtils) {
        return new JtaDefinesTransaction(new MongoTransactionManager(factory), mongoUtils);
    }
}
